package com.easylinkin.linkappapi.application.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easylinkin.linkappapi.application.entity.Application;
import com.easylinkin.linkappapi.application.entity.ApplicationRefDeviceUnit;
import com.easylinkin.linkappapi.application.entity.ApplicationRefPrivilege;
import com.easylinkin.linkappapi.deviceunit.entity.DeviceUnit;
import com.easylinkin.linkappapi.security.entity.LinkappPrivilege;
import com.easylinkin.linkappapi.tenant.entity.LinkappTenant;

/**
 * <p>
 * 应用管理表 Mapper 接口
 * </p>
 *
 * @author XuGuoQing
 * @since 2020-05-19
 */
public interface ApplicationMapper extends BaseMapper<Application> {


	IPage<Application> getApplicationByName(IPage page, @Param("name") String  name );

	List<DeviceUnit> selectDeviceUnitByApplication(@Param("id") String id);
	
	List<DeviceUnit> selectApplicationDeviceUnitByUser(@Param("id") String id);

	void deleteApplication2DeviceUnits(String id);

	void insertApplication2DeviceUnits(ApplicationRefDeviceUnit applicationRefDeviceUnit);

	List<LinkappPrivilege> selectPrivilegeByApplication(@Param("id") String id);

	void deleteApplication2Privileges(@Param("id") String id);

	void insertApplication2Privileges(ApplicationRefPrivilege applicationRefPrivilege);
	
	List<Application> selectApplicationByUser(@Param("id") String id);
	
	List<LinkappPrivilege> selectApplicationPrivilegeByUser(@Param("id") String id);
	
	void deleteTenant2DeviceUnits(@Param("deviceUnitId") String deviceUnitId,@Param("tenantId") String tenantId);
	
	void deleteTenant2Privileges(@Param("privilegeId") String privilegeId,@Param("tenantId") String tenantId);
	
	void deleteRole2Privileges(@Param("privilegeId") String privilegeId,@Param("tenantId") String tenantId);
	
	List<LinkappTenant> selectTenantByApplication(@Param("appKey") String appKey);

}
